<?php

$db_hostname = "localhost";
$db_database = "listings";
$db_username = "root";
$db_password = "hackme";

function db_access($db_query, $db_server) {
  global $db_hostname, $db_database, $db_username, $db_password;

  if (!$db_server) {
    die("Unable to connect to MySQL server: " . mysql_error());
  }

  mysql_select_db($db_database)
    or die("Unable to select database: " . mysql_error());

  $result = mysql_query($db_query, $db_server);

  if (!$result) {
    die("Query failed: " . mysql_error());
  }

  return $result;
}

?>
